# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=xapian-core
pkgver=1.4.26
pkgrel=0
pkgdesc="Open source search engine library"
url="http://www.xapian.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="zlib-dev util-linux-dev libtool"
subpackages="$pkgname-dev $pkgname-doc libxapian"
source="http://oligarchy.co.uk/xapian/$pkgver/xapian-core-$pkgver.tar.xz
	timeval-t.patch
	disable-failing-tests.patch"

# FIXME: On armhf the sortableserialise1 test case fails.
case "$CARCH" in
armhf) options="!check" ;;
esac

# secfixes:
#   1.4.6-r0:
#     - CVE-2018-0499

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	# Set AUTOMATED_TESTING here to skip tests which rely
	# heavily on timing and may thus fail the face of uneven
	# loads etc.
	#
	# See https://trac.xapian.org/ticket/764#comment:2
	make AUTOMATED_TESTING=1 VALGRIND= -C "$builddir" check
}

package() {
	make DESTDIR="$pkgdir" install
}

libxapian() {
	pkgdesc="Xapian search engine library"

	install -d "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/$subpkgname* "$subpkgdir"/usr/lib
}

sha512sums="
ecd94d410dc94b6510c6729f276606987f9dd955cfb0520e62d46fa71645f5b140d474cda0d77078e64ee7cf9c0cd00f3aefe0e1b087739582e64bbcb9fabd4b  xapian-core-1.4.26.tar.xz
639c0ecd75be0627d334628b5adf581a7da92c4f86dfb86a92669368ff8a874d4bf4e344b8f3b1276d22d126d2bc44c8ab727e39e1c29c0358fe7bbc8aa8050d  timeval-t.patch
a1a98befc36e148dce1f95b1f3b722d5d3d6d410575ce3d0b7d468f9596034d23b1fca47ec432ad03437ecd1eb09f0fc8d386340d266706766e067e0d1f24380  disable-failing-tests.patch
"
